

// 用户登录的 请求

import request from '@/utils/request.js'

// 登录
export const  login = async (data) => {
    return request({
        method: "post",
        url: '/v1_0/authorizations',
        data
    })
}


// 发送验证码
export const  sendSms = async (data) => {
    return request({
        method: "get",
        url: '/v1_0/sms.codes/'+data,
    })
}


// 请求用户信息
export const getUserInfo = () => {
    return request({
        method: "get",
        url: '/v1_0/user',
    })
}

// 请求全部频道列表
export const getPindao = () => {
    return request({
        method: "get",
        url: '/v1_0/channels',
    })
}

// 关注
export const addFollow = target => {
    return request({
        method: "POST",
        url: '/v1_0/user/followings',
        data: {
            target
        }
    })
}

// 取消关注
export const delFollow = target => {
    return request({
        method: "DELETE",
        url: `/v1_0/user/followings/${target}`,
    })
}


// 收藏
export const addShou = target => {
    return request({
        method: "POST",
        url: '/v1_0/article/collections',
        data: {
            target
        }
    })
}

// 取消收藏
export const delShou = target => {
    return request({
        method: "DELETE",
        url: `/v1_0/article/collections/${target}`,
    })
}

// 点赞
export const addLike = target => {
    return request({
        method: "POST",
        url: '/v1_0/article/likings',
        data: {
            target
        }
    })
}

// 取消点赞
export const delLike = target => {
    return request({
        method: "DELETE",
        url: `/v1_0/comment/likings/${target}`,
    })
}

// 获取个人资料
export const getUserFile = () => {
    return request({
        method: "get",
        url: `/v1_0/user/profile`,
    })
}

// 修改个人资料
export const emitUserFile = params => {
    return request({
        method: "PATCH",
        url: `/v1_0/user/profile`,
        data:params
        
    })
}


// 修改头像
export const emitPhoto = data => {
    return request({
        method: "PATCH",
        url: `/v1_0/user/photo`,
        data
        
    })
}